import { Module } from '@nestjs/common'
import { AuthController } from './auth.controller'
import { AuthService } from './auth.service'
import { UserMongoModule } from '@libs/db/schemas/user.schema'
import { PassportModule } from '@nestjs/passport'
import { LocalStrategy } from './loca.strategy'
import { JwtStrategy } from './jwt.strategy'
import { JwtModule } from '@nestjs/jwt'
import config from '../config'
@Module({
  imports: [
    UserMongoModule,
    PassportModule,
    JwtModule.registerAsync({
      // 改异步，需要等环境变量合并
      useFactory() {
        return {
          secret: config.server.scret,
          signOptions: { expiresIn: '6h' }, // Eg: 60, "2 days", "10h", "7d"
        }
      },
    }),
  ],
  controllers: [AuthController],
  providers: [AuthService, LocalStrategy, JwtStrategy],
  exports: [AuthService],
})
export class AuthModule {}
